home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.2 Development Libraries / SGI IRIX 6.2 Development Libraries.iso / dist / gl_dev.idb / usr / include / gl / dgl.h.z / dgl.h
Encoding:
C/C++ Source or Header  |  1996-03-15  |  23.4 KB  |  623 lines

  1. #ifndef __GL_DGL_H__
  2. #define __GL_DGL_H__
  3. /**************************************************************************
  4.  *                                      *
  5.  *          Copyright (C) 1989, Silicon Graphics, Inc.          *
  6.  *                                      *
  7.  *  These coded instructions, statements, and computer programs  contain  *
  8.  *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
  9.  *  are protected by Federal copyright law.  They  may  not be disclosed  *
  10.  *  to  third  parties  or copied or duplicated in any form, in whole or  *
  11.  *  in part, without the prior written consent of Silicon Graphics, Inc.  *
  12.  *                                      *
  13.  **************************************************************************/
  14. /*----------------------------------------------------------------------*/
  15. /* dgl.h */
  16. /*  - Header file used to build the DGL, its associated test programs,  */
  17. /*    and dgld. */
  18. /*  - No user application should ever include this file. */
  19. /* */
  20. /* $Revision: 1.30 $ */
  21. /*----------------------------------------------------------------------*/
  22.  
  23.  
  24. /*----------------------------------------------------------------------*/
  25. /*        SECTION 1 - machine dependent statements */
  26. /*----------------------------------------------------------------------*/
  27.  
  28. /*----------------------------------------------------------------------*/
  29. /* IRIS machine dependent statements */
  30. /*----------------------------------------------------------------------*/
  31. #if sgi
  32. #define MACHINE_WORD_FORMAT    DGL_BIG_ENDIAN
  33. #define MACHINE_FLOAT_FORMAT    DGL_BIG_IEEE
  34. #if m68000            /* on 3K, times() returns 60'ths regardless */
  35. #undef HZ
  36. #define HZ 60
  37. #define double long float    /* make m68020 behave like everyone else*/
  38. #endif /* m68000 */
  39. #endif /* sgi */
  40.  
  41. /*----------------------------------------------------------------------*/
  42. /* ALLIANT/BSD machine dependent statements */
  43. /*----------------------------------------------------------------------*/
  44. #ifdef ALLIANT
  45. #define alliant 1
  46. #define MACHINE_WORD_FORMAT    DGL_BIG_ENDIAN
  47. #define MACHINE_FLOAT_FORMAT    DGL_BIG_IEEE
  48.  
  49. #define __STDC__        /* need to define this when using pcc    */
  50.  
  51.                 /* ALLIANT default is signed chars    */
  52.                 /* Leave the rest of the next line empty*/
  53. #define signed
  54. #define h_errno errno        /* BSD has these merged???        */
  55. typedef unsigned long ulong;    /* missing from types.h            */
  56. #endif /* ALLIANT */
  57.  
  58. /*----------------------------------------------------------------------*/
  59. /* CONVEX machine dependent statements */
  60. /*----------------------------------------------------------------------*/
  61. #if convex
  62. #define MACHINE_WORD_FORMAT    DGL_BIG_ENDIAN
  63. #define MACHINE_FLOAT_FORMAT    DGL_BIG_IEEE
  64.  
  65. #undef HZ            /* times() returns 60'ths regardless    */
  66. #define HZ 60
  67. #define strchr index        /* strchr(s,c) equivalent to index(s,c) */
  68. #define signed            /* CONVEX default is signed chars    */
  69. #define h_errno errno        /* BSD has these merged???        */
  70. typedef unsigned long ulong;    /* missing from types.h            */
  71. #endif /* convex */
  72.  
  73. /*----------------------------------------------------------------------*/
  74. /* CRAY machine dependent statements */
  75. /*----------------------------------------------------------------------*/
  76. #ifdef CRAY
  77. #define MACHINE_WORD_FORMAT    DGL_BIG_ENDIAN
  78. #define MACHINE_FLOAT_FORMAT    DGL_BIG_IEEE
  79. #define signed            /* CRAY default is signed chars    */
  80. #include <use_stdc.h>        /* Make sure we use the ANSI C compiler. */
  81. #endif /* CRAY */
  82.  
  83. /*----------------------------------------------------------------------*/
  84. /* SUN/BSD machine dependent statements */
  85. /*----------------------------------------------------------------------*/
  86. #if sun
  87. #define MACHINE_WORD_FORMAT    DGL_BIG_ENDIAN
  88. #define MACHINE_FLOAT_FORMAT    DGL_BIG_IEEE
  89.  
  90. #define signed            /* SUN default is signed chars        */
  91. #define h_errno errno        /* BSD has these merged???        */
  92. typedef unsigned long ulong;    /* missing from types.h            */
  93. #endif /* sun */
  94.  
  95. /*----------------------------------------------------------------------*/
  96. /* VAX VMS/BSD machine dependent statements */
  97. /*----------------------------------------------------------------------*/
  98. #if vax
  99. #define MACHINE_WORD_FORMAT    DGL_LITTLE_ENDIAN
  100. #define MACHINE_FLOAT_FORMAT    DGL_NON_IEEE
  101.  
  102. #define signed            /* VAX default is signed chars        */
  103.  
  104. #if vms                /* VMS only statements            */
  105. #define    HZ    100        /* missing from param.h            */
  106.  
  107. #define dn_perror dgl_perror    /* use normal error handler        */
  108. #define fork vfork        /* just for now - doesn't really work    */
  109.  
  110. #else                /* VAX/BSD only statements        */
  111. #define HZ 60            /* missing from param.h            */
  112. typedef unsigned long ulong;    /* missing from types.h            */
  113. extern int errno;        /* missing from errno.h            */
  114. #endif /* vms */
  115. #endif /* vax */
  116.  
  117. /*----------------------------------------------------------------------*/
  118. /* IBM RS/6000 series machine dependent statements */
  119. /*----------------------------------------------------------------------*/
  120. #ifdef _IBMR2
  121. #define MACHINE_WORD_FORMAT    DGL_BIG_ENDIAN
  122. #define MACHINE_FLOAT_FORMAT    DGL_BIG_IEEE
  123. #undef DOUBLE    /* bogusly defined in <gai/g3dm2types.h> */
  124. #endif
  125.  
  126.  
  127. /*----------------------------------------------------------------------*/
  128. /* 32/64-bit architecture dependent statements */
  129. /*----------------------------------------------------------------------*/
  130. #ifdef CRAY
  131.  
  132. #define size_char 1
  133. #define size_short 2
  134. #define size_int 4
  135. #define size_long 4
  136. #define size_float 4
  137. #define size_double 8
  138. #define size_Fontchar 8
  139. #define size_Lfontchar 20
  140. #define size_fmglyphinfo 32
  141. #define size_fmfontinfo 212        /* careful with this one */
  142. #ifdef __STDC__
  143. #define SIZEOF(x) size_##x
  144. #else
  145. #define SIZEOF(x) size_/**/x
  146. #endif /*__STDC__*/  
  147.  
  148. /* These macros expect a pointer to the communications buffer; in the case of
  149.    a Cray they do nothing. */
  150. #define DGL_NTOH_LONG_CBUF(p)   {}
  151. #define DGL_NTOH_SHORT_CBUF(p)  {}
  152. #define DGL_NTOH_FLOAT_CBUF(p)  {}
  153.  
  154. /* Store a long(short) with no byteswapping conversion. */
  155. #define PUT_LONG(p,l)    DGL_HTON_LONG( p,l)
  156. #define PUT_SHORT(p,s)     DGL_HTON_SHORT( p,s)
  157.  
  158. /* Make an expression that interprets 4(2) chars as a long(short). */
  159. #define GET_LONG(p) \
  160.     ( (p)[0] & 0x80 ? \
  161.         ((p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8  | (p)[3]) \
  162.           | ~0xffffffff \
  163.      : ((p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8  | (p)[3]) \
  164.     )
  165. #define GET_SHORT(p) \
  166.     ( (p)[0] & 0x80 ? \
  167.         ((p)[0] << 8 | (p)[1]) | ~0xffff \
  168.       : ((p)[0] << 8 | (p)[1]) \
  169.     )
  170.  
  171. #else /* not CRAY */
  172. #define SIZEOF(x) sizeof(x)
  173.  
  174. /* These macros expect a pointer to the communications buffer; they perform
  175.    byteswapping conversion, if needed, on values found in the buffer. */
  176. #define DGL_NTOH_LONG_CBUF(p)   DGL_NTOH_LONG( LONG(p), LONG(p))
  177. #define DGL_NTOH_SHORT_CBUF(p)  DGL_NTOH_SHORT( SHORT(p), SHORT(p))
  178. #define DGL_NTOH_FLOAT_CBUF(p)  DGL_NTOH_FLOAT( FLOAT(p), FLOAT(p))
  179.  
  180. /* Store a long(short) with no byteswapping conversions. */
  181. #define PUT_LONG(p,l)    (LONG(p) = l)
  182. #define PUT_SHORT(p,s)     (SHORT(p) = s)
  183.  
  184. /* Make an expression that interprets 4(2) chars as a long(short). */
  185. #define GET_LONG(p)    LONG(p)
  186. #define GET_SHORT(p)     SHORT(p)
  187. #define GET_FLOAT(p)     FLOAT(p)
  188.  
  189. #endif /* ifdef CRAY */
  190.  
  191. /*----------------------------------------------------------------------*/
  192. /*        SECTION 2 - capability variables */
  193. /*----------------------------------------------------------------------*/
  194.  
  195. /*----------------------------------------------------------------------*/
  196. /* COMMUNICATION variables */
  197. /*----------------------------------------------------------------------*/
  198.                 
  199. /* supports LOCAL connections */
  200. #define GLLOCAL (sgi && mips)    /* only 4D's, not 3K's */
  201.  
  202. /* supports TCP socket connections */
  203. #define GLTSOCKET sgi || sun || convex || (vax && !vms) || _IBMR2 || cray
  204.  
  205. /* supports DECnet connections */
  206. #define GL4DDN    (sgi && mips) || vms    /* 4DDN is only on 4Ds, not 3K's */
  207.  
  208. /*----------------------------------------------------------------------*/
  209. /* SYSTEM/LIBRARY variables */
  210. /*----------------------------------------------------------------------*/
  211. #define CUSERID BSD        /* use our own cuserid() subroutine    */
  212. #define DOPRNT    vms        /* use our own _doprnt subroutine    */
  213. #define GETTIMEOFDAY vms    /* use our own gettimeofday subroutine    */
  214.  
  215. /* private definitions for DGLTYPE variable
  216.  * public values are
  217.  * DGLSINK    0
  218.  * DGLLOCAL    1
  219.  * DGLTSOCKET    2
  220.  * DGL4DDN    3
  221.  */
  222. #define DGLNOTYPE        4    /* default connection    */
  223. #define DGLNOHOST        5    /* default hostname    */
  224.  
  225.  
  226. /*----------------------------------------------------------------------*/
  227. /* MACHINE CAPABILITY variables */
  228. /*----------------------------------------------------------------------*/
  229. #define WORDALIGN mips        /* requires word alignment on copies    */
  230.  
  231.  
  232. /*----------------------------------------------------------------------*/
  233. /*        SECTION 3 - GL renaming macros */
  234. /*----------------------------------------------------------------------*/
  235.  
  236. /* 
  237.  * GLCMD is the macro used to redefine all GL names
  238.  * FGLCMD is the macro used to redefine all FGL names
  239.  */
  240.  
  241. #ifdef GLBUILD
  242. #define GLCMD(name) gl_d_/**/name
  243. #else
  244. #define GLCMD(name) name
  245. #endif
  246.  
  247. #ifdef    __STDC__
  248. #define FGLCMD(name) name##_    
  249. #else
  250. #define FGLCMD(name) name/**/_
  251. #endif
  252.  
  253. #if defined(CRAY) && defined(LIBFGL)
  254. #define FGLNAME(lower,upper) FGLCMD(upper)    /* upper case externals */
  255. #else
  256. #define FGLNAME(lower,upper) FGLCMD(lower)    /* lower case externals */
  257. #endif
  258.  
  259.  
  260. /*----------------------------------------------------------------------*/
  261. /*        SECTION 4 - data conversion */
  262. /*----------------------------------------------------------------------*/
  263.  
  264. /*----------------------------------------------------------------------*/
  265. /* first some defines for the various data formats */
  266. /*----------------------------------------------------------------------*/
  267. #define DGL_LITTLE_ENDIAN 1        /* integer formats        */
  268. #define DGL_BIG_ENDIAN 2
  269.  
  270. #define DGL_BIG_IEEE 1        /* floating point formats    */
  271. #define DGL_NON_IEEE 3
  272.  
  273. /*----------------------------------------------------------------------*/
  274. /* here are the data conversion (byte swapping) algorithms */
  275. /*    HTON - client host to network (server) */
  276. /*    NTOH - network (server) to client host */
  277. /*----------------------------------------------------------------------*/
  278.  
  279. /*----------------------------------------------------------------------*/
  280. /* these macros are the same on all machines because chars need no */
  281. /* conversion whatsoever */
  282. /*----------------------------------------------------------------------*/
  283. #define DGL_HTON_CHAR(t,f) t=f
  284. #define DGL_NTOH_CHAR DGL_HTON_CHAR
  285. #define DGL_HTON_CHAR_ARRAY gl_mem_copy_array
  286. #define DGL_NTOH_CHAR_ARRAY gl_mem_copy_array
  287.  
  288. /*----------------------------------------------------------------------*/
  289. /* these macros are the same on all machines because the procedure */
  290. /* code invokes the appropriate conversion macro within a loop */
  291. /*----------------------------------------------------------------------*/
  292. #define DGL_HTON_SHORT_ARRAY gl_mem_hton_short_array
  293. #define DGL_NTOH_SHORT_ARRAY gl_mem_ntoh_short_array
  294. #define DGL_HTON_LONG_ARRAY gl_mem_hton_long_array
  295. #define DGL_NTOH_LONG_ARRAY gl_mem_ntoh_long_array
  296. #define DGL_HTON_FLOAT_ARRAY gl_mem_hton_float_array
  297. #define DGL_NTOH_FLOAT_ARRAY gl_mem_ntoh_float_array
  298. #define DGL_HTON_DOUBLE_ARRAY gl_mem_hton_double_array
  299. #define DGL_NTOH_DOUBLE_ARRAY gl_mem_ntoh_double_array
  300. #define DGL_HTON_FONTCHAR_ARRAY gl_mem_hton_fontchar_array
  301. #define DGL_NTOH_FONTCHAR_ARRAY gl_mem_ntoh_fontchar_array
  302. #define DGL_HTON_LFONTCHAR_ARRAY gl_mem_hton_lfontchar_array
  303. #define DGL_NTOH_LFONTCHAR_ARRAY gl_mem_ntoh_lfontchar_array
  304. #define DGL_HTON_FMFONTINFO_ARRAY gl_mem_hton_fmfontinfo_array
  305. #define DGL_NTOH_FMFONTINFO_ARRAY gl_mem_ntoh_fmfontinfo_array
  306. #define DGL_HTON_FMGLYPHINFO_ARRAY gl_mem_hton_fmglyphinfo_array
  307. #define DGL_NTOH_FMGLYPHINFO_ARRAY gl_mem_ntoh_fmglyphinfo_array
  308. #define DGL_NTOH_WFMOUTLINE_ARRAY gl_mem_ntoh_wfmoutline_array
  309.  
  310. /*----------------------------------------------------------------------*/
  311. /* DGL_BIG_ENDIAN: no conversion necessary (INTEGER) */
  312. /*----------------------------------------------------------------------*/
  313. #ifdef    CRAY
  314. extern long dgl_ntoh_long();
  315. extern short dgl_ntoh_short();
  316. #define DGL_HTON_CMD(t,f) DGL_HTON_LONG(t,f)
  317. #define DGL_NTOH_LONG(t,f)  t = dgl_ntoh_long(f)
  318. #define DGL_NTOH_SHORT(t,f)  t = dgl_ntoh_short(f)
  319. #else
  320. #if MACHINE_WORD_FORMAT == DGL_BIG_ENDIAN
  321. #define DGL_HTON_CMD(t,f) t = f        
  322. #define DGL_HTON_SHORT(t,f) t = f
  323. #define DGL_NTOH_SHORT DGL_HTON_SHORT
  324. #define DGL_HTON_LONG(t,f) t = f
  325. #define DGL_NTOH_LONG DGL_HTON_LONG
  326. #endif
  327. #endif
  328.  
  329. /*----------------------------------------------------------------------*/
  330. /* DGL_BIG_IEEE: no conversion necessary (FLOAT) */
  331. /*----------------------------------------------------------------------*/
  332. #ifdef CRAY
  333. extern float dgl_ntoh_float();
  334. extern float dgl_ntoh_double();
  335. #define DGL_NTOH_FLOAT(t,f)  t = dgl_ntoh_float(f)
  336. #define DGL_NTOH_DOUBLE(t,f)  t = dgl_ntoh_double(f)
  337. #else     /* !CRAY */
  338. #if MACHINE_FLOAT_FORMAT == DGL_BIG_IEEE
  339. #define DGL_HTON_FLOAT(t,f) t = f
  340. #define DGL_NTOH_FLOAT DGL_HTON_FLOAT
  341. #define DGL_HTON_DOUBLE(t,f) memcpy(&(t),&(f),sizeof(double))
  342. #define DGL_NTOH_DOUBLE DGL_HTON_DOUBLE
  343. #endif
  344. #endif
  345.  
  346. /*----------------------------------------------------------------------*/
  347. /* DGL_LITTLE_ENDIAN: conversion necessary (INTEGER) */
  348. /*    NOTE: non-floating point conversions are the same for both */
  349. /*        directions and thus one macro suffices */
  350. /*----------------------------------------------------------------------*/
  351. #if MACHINE_WORD_FORMAT == DGL_LITTLE_ENDIAN
  352. /* like DGL_HTON_LONG, but more efficient if f is a constant */
  353. #define DGL_HTON_CMD(t,f)  t = (f << 24) | ((f & 0xff00) << 8) |    \
  354.             ((f & 0xff0000) >> 8) | ((f >> 24) & 0xff)
  355. #define DGL_HTON_SHORT(t,f)     \
  356.     {            \
  357.         short _from = f,_to;    \
  358.         ((char *)&_to)[0] = ((char *)&_from)[1];    \
  359.         ((char *)&_to)[1] = ((char *)&_from)[0];    \
  360.         t = _to;    \
  361.     }
  362. #define DGL_NTOH_SHORT DGL_HTON_SHORT
  363. #define DGL_HTON_LONG(t,f)    \
  364.     {            \
  365.         long _from = f,_to;    \
  366.         ((char *)&_to)[0] = ((char *)&_from)[3];    \
  367.         ((char *)&_to)[1] = ((char *)&_from)[2];    \
  368.         ((char *)&_to)[2] = ((char *)&_from)[1];    \
  369.         ((char *)&_to)[3] = ((char *)&_from)[0];    \
  370.         t = _to;    \
  371.     }
  372. #define DGL_NTOH_LONG DGL_HTON_LONG
  373. #endif
  374.  
  375. /*----------------------------------------------------------------------*/
  376. /* DGL_NON_IEEE: conversion necessary (FLOAT) */
  377. /*    conversion is done within procedure calls for simplicity */
  378. /*----------------------------------------------------------------------*/
  379. #if MACHINE_FLOAT_FORMAT == DGL_NON_IEEE
  380. #define DGL_HTON_FLOAT(t,f) gl_mem_hton_float(&t,&f)
  381. #define DGL_NTOH_FLOAT(t,f) gl_mem_ntoh_float(&t,&f)
  382. #define DGL_HTON_DOUBLE(t,f) gl_mem_hton_double(&t,&f)
  383. #define DGL_NTOH_DOUBLE(t,f) gl_mem_ntoh_double(&t,&f)
  384. #endif
  385.  
  386. /*----------------------------------------------------------------------*/
  387. /* copy & convert a fontchar structure */
  388. /*----------------------------------------------------------------------*/
  389. #ifdef CRAY
  390. #define DGL_HTON_FONTCHAR(t,f)    {        \
  391.     ((char *)t)[0] = (f).offset >> 8;     \
  392.     ((char *)t)[1] = (f).offset;         \
  393.     ((char *)t)[2] = (f).w;            \
  394.     ((char *)t)[3] = (f).h;            \
  395.     ((char *)t)[4] = (f).xoff;        \
  396.     ((char *)t)[5] = (f).yoff;        \
  397.     ((char *)t)[6] = (f).width >> 8;    \
  398.     ((char *)t)[7] = (f).width;        \
  399. }
  400. #define DGL_NTOH_FONTCHAR(t,f)    {        \
  401.     (t).offset = ((unsigned char *)f)[0] << 8 | ((unsigned char *)f)[1];    \
  402.     (t).w    = ((unsigned char *)f)[2];    \
  403.     (t).h    = ((unsigned char *)f)[3];    \
  404.     (t).xoff = ((unsigned char *)f)[4];    \
  405.     (t).yoff = ((unsigned char *)f)[5];    \
  406.     (t).width = ((unsigned char *)f)[6] << 8 | ((unsigned char *)f)[7];    \
  407.     if (((unsigned char *)f)[6] & 0x80)    \
  408.         (t).width |= ~0xffff;        \
  409. }
  410. #define DGL_HTON_LFONTCHAR(t,f)    {        \
  411.     ((char *)t)[0] = (f).value >> 24;     \
  412.     ((char *)t)[1] = (f).value >> 16;     \
  413.     ((char *)t)[2] = (f).value >> 8;     \
  414.     ((char *)t)[3] = (f).value;         \
  415.     ((char *)t)[4] = (f).offset >> 24;     \
  416.     ((char *)t)[5] = (f).offset >> 16;     \
  417.     ((char *)t)[6] = (f).offset >> 8;     \
  418.     ((char *)t)[7] = (f).offset;         \
  419.     ((char *)t)[8] = (f).w >> 8;        \
  420.     ((char *)t)[9] = (f).w;            \
  421.     ((char *)t)[10] = (f).h >> 8;        \
  422.     ((char *)t)[11] = (f).h;        \
  423.     ((char *)t)[12] = (f).xoff >> 8;    \
  424.     ((char *)t)[13] = (f).xoff;        \
  425.     ((char *)t)[14] = (f).yoff >> 8;    \
  426.     ((char *)t)[15] = (f).yoff;        \
  427.     ((char *)t)[16] = (f).xmove >> 8;    \
  428.     ((char *)t)[17] = (f).xmove;        \
  429.     ((char *)t)[18] = (f).ymove >> 8;    \
  430.     ((char *)t)[19] = (f).ymove;        \
  431. }
  432. #define DGL_NTOH_LFONTCHAR(t,f)    {        \
  433.     (t).value = ((unsigned char *)f)[0] << 24 | ((unsigned char *)f)[1] << 16 | ((unsigned char *)f)[2] << 8 | ((unsigned char *)f)[3]; \
  434.     (t).offset = ((unsigned char *)f)[4] << 24 | ((unsigned char *)f)[5] << 16 | ((unsigned char *)f)[6] << 8 | ((unsigned char *)f)[7]; \
  435.     (t).w = ((unsigned char *)f)[8] << 8 | ((unsigned char *)f)[9]; \
  436.     if (((unsigned char *)f)[8] & 0x80)    \
  437.         (t).w |= ~0xffff;        \
  438.     (t).h = ((unsigned char *)f)[10] << 8 | ((unsigned char *)f)[11]; \
  439.     if (((unsigned char *)f)[10] & 0x80)    \
  440.         (t).h |= ~0xffff;        \
  441.     (t).xoff = ((unsigned char *)f)[12] << 8 | ((unsigned char *)f)[13]; \
  442.     if (((unsigned char *)f)[12] & 0x80)    \
  443.         (t).xoff |= ~0xffff;        \
  444.     (t).yoff = ((unsigned char *)f)[14] << 8 | ((unsigned char *)f)[15]; \
  445.     if (((unsigned char *)f)[14] & 0x80)    \
  446.         (t).yoff |= ~0xffff;        \
  447.     (t).xmove = ((unsigned char *)f)[16] << 8 | ((unsigned char *)f)[17]; \
  448.     if (((unsigned char *)f)[16] & 0x80)    \
  449.         (t).xmove |= ~0xffff;        \
  450.     (t).ymove = ((unsigned char *)f)[18] << 8 | ((unsigned char *)f)[19]; \
  451.     if (((unsigned char *)f)[18] & 0x80)    \
  452.         (t).ymove |= ~0xffff;        \
  453. }
  454. #else
  455. #define DGL_HTON_FONTCHAR(t,f)    {        \
  456.     DGL_HTON_SHORT((t).offset,(f).offset);    \
  457.     DGL_HTON_CHAR((t).w,(f).w);        \
  458.     DGL_HTON_CHAR((t).h,(f).h);        \
  459.     DGL_HTON_CHAR((t).xoff,(f).xoff);    \
  460.     DGL_HTON_CHAR((t).yoff,(f).yoff);    \
  461.     DGL_HTON_SHORT((t).width,(f).width);    \
  462. }
  463. #define DGL_NTOH_FONTCHAR DGL_HTON_FONTCHAR
  464. #define DGL_HTON_LFONTCHAR(t,f)    {        \
  465.     DGL_HTON_LONG((t).value,(f).value);        \
  466.     DGL_HTON_LONG((t).offset,(f).offset);    \
  467.     DGL_HTON_SHORT((t).w,(f).w);        \
  468.     DGL_HTON_SHORT((t).h,(f).h);        \
  469.     DGL_HTON_SHORT((t).xoff,(f).xoff);    \
  470.     DGL_HTON_SHORT((t).yoff,(f).yoff);    \
  471.     DGL_HTON_SHORT((t).xmove,(f).xmove);    \
  472.     DGL_HTON_SHORT((t).ymove,(f).ymove);    \
  473. }
  474. #define DGL_NTOH_LFONTCHAR DGL_HTON_LFONTCHAR
  475.  
  476. #define DGL_HTON_FMGLYPHINFO(t,f)    {        \
  477.     DGL_HTON_LONG((t).xsize,(f).xsize);    \
  478.     DGL_HTON_LONG((t).ysize,(f).ysize);    \
  479.     DGL_HTON_LONG((t).xorig,(f).xorig);    \
  480.     DGL_HTON_LONG((t).yorig,(f).yorig);    \
  481.     DGL_HTON_FLOAT((t).xmove,(f).xmove);    \
  482.     DGL_HTON_FLOAT((t).ymove,(f).ymove);    \
  483.     DGL_HTON_LONG((t).gtype,(f).gtype);    \
  484.     DGL_HTON_LONG((t).bitsdeep,(f).bitsdeep);    \
  485. }
  486. #define DGL_NTOH_FMGLYPHINFO DGL_HTON_FMGLYPHINFO
  487.  
  488. #define DGL_HTON_FMFONTINFO(t,f)    {        \
  489.     DGL_HTON_LONG((t).printermatched,(f).printermatched);    \
  490.     DGL_HTON_LONG((t).reserved0,(f).reserved0);    \
  491.     DGL_HTON_DOUBLE((t).matrix00,(f).matrix00);    \
  492.     DGL_HTON_DOUBLE((t).matrix01,(f).matrix01);    \
  493.     DGL_HTON_DOUBLE((t).matrix10,(f).matrix10);    \
  494.     DGL_HTON_DOUBLE((t).matrix11,(f).matrix11);    \
  495.     DGL_HTON_LONG((t).type,(f).type);    \
  496.     DGL_HTON_LONG((t).encoding,(f).encoding);    \
  497.     DGL_HTON_LONG((t).fixed_width,(f).fixed_width);    \
  498.     DGL_HTON_LONG((t).xorig,(f).xorig);    \
  499.     DGL_HTON_LONG((t).yorig,(f).yorig);    \
  500.     DGL_HTON_LONG((t).xsize,(f).xsize);    \
  501.     DGL_HTON_LONG((t).ysize,(f).ysize);    \
  502.     DGL_HTON_LONG((t).height,(f).height);    \
  503.     DGL_HTON_LONG((t).nglyphs,(f).nglyphs);    \
  504.     DGL_HTON_LONG((t).bitsdeep,(f).bitsdeep);    \
  505.     DGL_HTON_LONG((t).width,(f).width);    \
  506.     DGL_HTON_LONG((t).resolution,(f).resolution);    \
  507.     DGL_HTON_LONG((t).weight,(f).weight);    \
  508.     DGL_HTON_LONG((t).reserved1,(f).reserved1);    \
  509.     DGL_HTON_LONG((t).reserved2,(f).reserved2);    \
  510.     DGL_HTON_LONG((t).reserved3,(f).reserved3);    \
  511. }
  512. #define DGL_NTOH_FMFONTINFO DGL_HTON_FMFONTINFO
  513. #endif     /* CRAY */
  514.  
  515. /*----------------------------------------------------------------------*/
  516. /*            SECTION 5 - internal DGL statements */
  517. /*             *** DO NOT CHANGE ANYTHING BELOW HERE *** */
  518. /*----------------------------------------------------------------------*/
  519.  
  520. #ifndef NULL            /* define NULL in not already defined    */
  521. #define NULL    0
  522. #endif
  523.  
  524. #define DGL_VERSION 1        /* old DGL version number        */
  525. #define DGL_NEW_VERSION 2    /* current DGL version (supports Xauthority) */
  526. #define CMD_SPECIAL 0x00001234    /* special token to check byte ordering    */
  527. #define RETAINED 0x80000000    /* special negative number for arrays    */
  528. #define MAXARGS 100        /* maximum number of args per DGL routine */
  529. #define MAXCALLBACKS 16        /* maximum number of callback procedures*/
  530. #define COMMBUFSIZE (4*1024)    /* default comm buffer size in bytes    */
  531. #define AVGSIZE 20        /* average size (bytes) of command    */
  532. #define END_OF_BUFFER 0        /* special DGL command token        */
  533. #define DGL_NOP -1        /* special DGL command token        */
  534. #define RESET_COMM_CURBUFPOS comm_curbufpos = comm_buffer + 4
  535. #define RESET_COMM_ENDBUFFER    \
  536.     comm_endbuffer = comm_buffer + comm_stdsize - 4 - AVGSIZE
  537.  
  538. #define MAX_GFILES 256        /* maximum number of gfiles        */
  539. #define DGL_MAXIO 0x37777770    /* maximum number of bytes per i/o    */
  540. #define DGL_LASTFRAG 0x10000000    /* high bit of 32 bit word        */
  541.  
  542. /*----------------------------------------------------------------------*/
  543. /* get/set a data item located at address p regardless what it really is */
  544. /*----------------------------------------------------------------------*/
  545. #ifdef CRAY
  546. #define LONG(p) (p)
  547. #define FLOAT(p) (p)
  548. #define DOUBLE(p) (p)
  549. #define SHORT(p) (p)
  550. #define FONTCHAR(p) (p)
  551. #define LFONTCHAR(p) (p)
  552. #define CHAR(p) (*(char *)(p))
  553. #else /* !CRAY */
  554. #define LONG(p) (*(long *)(p))
  555. #define FLOAT(p) (*(float *)(p))
  556. #define DOUBLE(p) (*(double *)(p))
  557. #define SHORT(p) (*(short *)(p))
  558. #define CHAR(p) (*(char *)(p))
  559. #define FONTCHAR(p) (*(Fontchar *)(p))
  560. #define LFONTCHAR(p) (*(Lfontchar *)(p))
  561. #define FMGLYPHINFO(p) (*(fmglyphinfo *)(p))
  562. #define FMFONTINFO(p) (*(fmfontinfo *)(p))
  563. #endif
  564.  
  565. /*----------------------------------------------------------------------*/
  566. /* this is the graphics file data structure */
  567. /*----------------------------------------------------------------------*/
  568. typedef struct gfile {
  569.     int id;            /* my id (index into table)        */
  570.     int type;            /* type of connection            */
  571.     int maxio;            /* maximum bytes for one i/o operation    */
  572.     int fd_read;        /* file descriptor for reading        */
  573.     int fd_write;        /* file descriptor for writing        */
  574.     int fd_extra;        /* extra one for special hacks        */
  575.     int (*readproc)();        /* read data procedure            */
  576.     int (*writeproc)();        /* write data procedure            */
  577.     int (*closeproc)();        /* close file procedure            */
  578.     char fname_read [80];    /* the 2 file names            */
  579.     char fname_write[80];
  580.     int fd_queue;        /* queue file descriptor        */
  581.     char rhost[200];
  582.     int floatfeedback;        /* boolean: use floats or shorts    */
  583.     int isdefault;        /* this is default connection        */
  584.     int is4xrelease;        /* this connection to a 4.0.x release    */
  585. } Gfile;
  586.  
  587. extern Gfile *comm_gfiles[];    /* all the gfiles            */
  588. extern Gfile *comm_curgfile;    /* the current gfile            */
  589.  
  590. extern char *comm_buffer;            /* THE BUFFER        */
  591.  
  592. extern long dgl_debug;                /* debug flag        */
  593. extern int dgl_errors;                /* error counter    */
  594. extern int dgl_testmode;            /* test mode flag    */
  595. extern int dgl_exitflag;            /* exit flag        */
  596. extern int dgl_glprof;                /* profiling flag    */
  597. extern int dgl_positional;            /* test variable    */
  598. extern int (*dgl_interpreter)();        /* the dgl interpreter    */
  599.  
  600. extern float gl_util_timer();            /* utility timer    */
  601.  
  602. /* dgld versions follow */
  603.  
  604. extern Gfile *dcom_gfiles[];    /* all the gfiles            */
  605. extern Gfile *dcom_curgfile;    /* the current gfile            */
  606.  
  607. extern char *dgld_myname;            /* the program's name    */
  608. extern char *dcom_buffer;            /* THE BUFFER        */
  609.  
  610. extern long dgld_debug;                /* debug flag        */
  611. extern int dgld_errors;                /* error counter    */
  612. extern int dgld_testmode;            /* test mode flag    */
  613. extern int dgld_exitflag;            /* exit flag        */
  614. extern int dgld_glprof;                /* profiling flag    */
  615. extern int dgld_positional;            /* test variable    */
  616. extern int (*dgld_interpreter)();        /* the dgl interpreter    */
  617.  
  618. extern signed char gen_char();            /* test routine        */
  619. extern float gen_float();            /* test routine        */
  620. extern float util_timer();            /* utility timer    */
  621.  
  622. #endif /* __GL_DGL_H__ */
  623.